package com.ailink.design.pattern.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Created by Administrator on 2018/8/6
 */
public class Test {
    public static void main(String[] args) {
        SuperCar superCar = new SuperCar();
        InvocationHandler h = new TimeHandler(superCar);
        Function function = (Function) Proxy.newProxyInstance(superCar.getClass().getClassLoader(), superCar.getClass().getInterfaces(), h);
        function.move();
        function.fly(5000);
//        Car car = new Car();
//        Class<?> cls = car.getClass();
//        car.move();
//        Movable movable = new NewCar();
//        movable.move();
//        Movable movable2 = new CarLogProxy(car);
//        Movable movable1 = new CarTimeProxy(movable2);
//        movable1.move();
//        Movable movable = (Movable) Proxy.newProxyInstance(cls.getClassLoader(), cls.getInterfaces(), h);
//        movable.move();
    }
}
